{{!

  Copyright (c) Meta Platforms, Inc. and affiliates.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

}}
  {{#if (not function.bidirectional_stream?)}}
value = {{^function.stream?}}await {{/function.stream?}}self.{{function.name}}({{#function.params.fields}}args_struct.{{field:py_name}},{{/function.params.fields}})
    {{#if function.stream?}}
      {{#if function.stream_has_first_response?}}
value, stream = await value
      {{#else}}
stream = value
       {{/if function.stream_has_first_response?}}
if not isinstance(stream, _typing.AsyncIterator):
    stream = await stream
    {{/if function.stream?}}
    {{#if function.sink?}}
      {{#if function.sink_has_first_response?}}
value, sink_callback = value
      {{#else}}
sink_callback = value
      {{/if function.sink_has_first_response?}}
    {{/if function.sink?}}
    {{#if (not function.oneway?)}}
return_struct = {{#partial m_functions.return_type service=service function=function}}({{#if function.with_regular_response?}}success=value{{/if}})
    {{/if (not function.oneway?)}}
    {{#if function.stream?}}
return_stream = self._fbthrift__stream_wrapper_{{function.name}}(stream, protocol)
    {{/if function.stream?}}
    {{#if function.sink?}}
return_sink_callback = self._fbthrift__sink_wrapper_{{function.name}}(sink_callback, protocol)
    {{/if function.sink?}}
  {{#else}}
value = await self.{{function.name}}({{#function.params.fields}}args_struct.{{field:py_name}},{{/function.params.fields}})
    {{#if function.stream_has_first_response?}}
value, bidi_callback = value
return_struct = {{#partial m_functions.return_type service=service function=function}}(success=value)
    {{#else}}{{! Stream has first response }}
bidi_callback = value
return_struct = {{#partial m_functions.return_type service=service function=function}}()
    {{/if function.stream_has_first_response?}}
return_bidi_callback = self._fbthrift__bidi_wrapper_{{function.name}}(bidi_callback, protocol)
  {{/if (not function.bidirectional_stream?)}}
